package cn.donting.jme.edit.ui.scenetree;

import cn.donting.jme.edit.ex.IconResourcesLoader;
import cn.donting.jme.edit.ex.ExResourcesLoad;
import com.jme3.scene.Spatial;
import javafx.scene.control.TreeItem;
import javafx.scene.image.ImageView;
import lombok.Getter;

public class SpatialTreeItem extends TreeItem<String> {

    @Getter
    private Spatial spatial;

    public SpatialTreeItem(Spatial value) {
        super(value.toString());
        spatial=value;
        init();
    }

    private void init() {
        IconResourcesLoader firstResources = ExResourcesLoad.getFirstResources(IconResourcesLoader.class);
        ImageView icon = firstResources.getIcon(spatial);
        if(icon!=null){
            icon.setFitHeight(16);
            icon.setFitWidth(16);
            setGraphic(icon);
        }
    }
}
